import { createSlice } from '@reduxjs/toolkit'

export const counterSlice = createSlice({
    name: 'counter',
    initialState:{
        history:['中医','皮肤','痛风','风湿病','慢性胃炎','减肥']
    },
    reducers: {
        // 新增历史搜索记录
        addHistory(state,action){
            state.history.unshift(action.payload)
        },
        // 清空搜索历史
        clearHistory(state){
            state.history = []
        }
    },
})

export const { addHistory, clearHistory } = counterSlice.actions

export default counterSlice.reducer